1. Field of the Description
The present description relates, in general, to memory management in computer systems and virtual machine environments, including Java™ virtual machines (JVMs), and, more particularly, to methods and systems for providing garbage collection suited for small systems (e.g., with relatively few active application threads such as less than about 100 threads) to reduce contention when accessing update buffers made available by application threads (also known as mutator threads). Generally, though, the method applies to communicating any information from application/mutator threads to garbage collector (GC) threads (e.g., GC threads being a proxy for the GC/memory management subsystem and buffers containing object reference update information providing just one example of such information). The method ensures that the application threads get better latencies, possibly at the expense of the GC threads (e.g., all threads are not treated equally with regard to latency in some embodiments of the described method).
2. Relevant Background
In a computer system, the effective control of the allocation of memory resources is desirable to the successful operation and scalability of the computer system (e.g., the whole hardware stack, operating system (OS), Java™ Virtual Machine (JVM), software, and the like). Software applications run more efficiently in environments in which steps are taken to proactively manage available memory resources to ensure that only those entities or data objects that are currently being used are stored in memory, while unused entities or data objects are cleanly removed. In some systems and virtual machines (for example, the JVM), the system periodically performs garbage collection using one or more garbage collector (GC) threads. During garbage collection, the virtual machine scans the entire data object memory (or application heap) and finds which objects stored in the heap are currently in use and which objects the program can no longer reference. The areas of the heap occupied by unreferenceable objects are then returned to the virtual machine for subsequent use.
Generally, garbage collection (GC) is a form of automatic memory management that frees a programmer from worry about releasing no-longer used memory resources. Typically, garbage collector threads are used in the context of, or in computing environments involving, programming languages that allocate memory as data objects. For example, each application (or its threads) may have a pool of data objects in its heap, and garbage collector threads find out which of these data objects are unreachable and reclaims them. A garbage collector thread consumes finite computing resources performing actions that manage the process of deciding what memory is to be freed and when and how such memory should be made available to an application (or application threads). Hence, a penalty for using garbage collectors is GC-created overhead leading to decreased application processing efficiency. More particularly, in garbage collected runtime environments, it is often the case that mutator threads must notify the garbage collector of updates they perform on object reference fields. This information can be used by the garbage collector in several ways such as to update remembered sets to ensure correct operation of an incremental marking scheme.
There are many ways to record object reference field updates. One technique involves dirtying entries of a card table to notify the garbage collector which areas or “cards” of the heap contain modified objects. In another technique, update buffers are generated that contain information about each update a mutator thread has performed, and garbage collector threads periodically read and process these buffers. In this latter garbage collection approach, the update buffers are typically added by mutator threads to a global queue (or global input buffer queue) and removed from the global queue by garbage collector threads. An atomic operation, such as a lock or compare and swap (CAS) operation, must be used to add and/or remove an update buffer to or from the queue. A point of contention between GC threads may arise as buffers are added and removed from the global queue that limits scalability and performance of the computer systems implementing such a garbage collection process.
Hence, there is a need for improved methods of providing garbage collection with less contention to memory and/or other resources of a computing system. Preferably, such garbage collection methods and systems may provide data structures that cause (or allow) applications to do as little work as possible while causing the garbage collector thread(s) to do more work (e.g., create a desired asymmetry in which garbage collector thread(s) may have more latency than mutator threads).